import { h } from 'vue';
import { ElButton } from 'element-plus';
import { definePlugin } from '@/components/@comp/create-component';
import { usePopupManage } from '@/components/@comp/popup-manage';

export default definePlugin({
  name: 'buttonList',
  priority: 'CONTENT',
  extendProps: {
    columns: Array,
  },
  useMain(instance, props) {
    // console.log(props);

    const { request } = instance.getPlugin('request');

    const { popup } = usePopupManage();

    console.log(popup);

    return {
      buttonBar: () =>
        h(
          'div',
          { style: { width: '100%', display: 'flex', justifyContent: 'flex-end' } },
          {
            default: () => [
              h(
                ElButton,
                {
                  type: 'primary',
                  onClick: request.refresh,
                },
                () => '刷新',
              ),
              h(ElButton, { type: 'primary', onClick: () => popup.open('global/role-update') }, () => '新增'),
            ],
          },
        ),
    };
  },
});
